let http = require("http");
let fs = require("fs");

let server = http.createServer();

server.on('request', (req, res) => {
    console.log(req.url);
    res.setHeader("Content-Type", "text/html; charset=utf-8");
    // res.write("欢迎" + '<br />' + '<a href="http://www.baidu.com">点击跳转到百度</a>');
    if (req.url == '/index.html') {
       let buf = fs.readFileSync('./login.html');
       res.write(buf);
    }
    res.end("end");
})

server.listen(8080, () => {
    console.log('server running at http://127.0.0.1:8080')
})
